﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using DSD_CINE.Dominio;
using System.Data;
using System.Data.SqlClient;

namespace DSD_CINE.Persistencia
{

    public class PeliculaDAO
    {


        public List<BE_PELICULA> ListarTodos(string id)
        {
            List<BE_PELICULA> lstPeliculaBE = new List<BE_PELICULA>();
            BE_PELICULA bePelicula = null;
            String sSQL = "";
            sSQL = "set language spanish EXEC sp_peliculasxcine '";
            sSQL += id + "'";
            using (SqlConnection con = new SqlConnection(ConexionUtil.Conexion))
            {

                con.Open();
                using (SqlCommand com = new SqlCommand(sSQL, con))
                {
                    using (SqlDataReader resultado = com.ExecuteReader())
                    {
                        while (resultado.Read())
                        {
                            bePelicula = new BE_PELICULA()
                            {
                                PeliculaID = (string)resultado["pelicula_ID"],
                                Titulo = (string)resultado["titulo"]
                            };
                            lstPeliculaBE.Add(bePelicula);
                        }

                    }

                }

            }
            return lstPeliculaBE;

        }
    }
}